package com.example.touch.domain;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;

import android.graphics.Point;

public class EventActionRule 
{
	private String eventID;
	private Collection<EventTrigger> eventTriggers;
	private Collection<IActivityAction> actions;

	public EventActionRule()
	{
		eventTriggers = new ArrayList<EventTrigger>();
		actions = new ArrayList<IActivityAction>();
	}
	
	public boolean shouldTriggerActions(Point currentPosition, Calendar now)
	{
		for(EventTrigger trigger : eventTriggers)
		{
			if(trigger.evaluate(currentPosition, now))
				return true;
		}
		
		return false;
	}
	
	public void invokeAllActions()
	{
		for(IActivityAction action : actions)
		{
			action.invoke();
		}
	}
	
	public String getID()
	{
		return eventID;
	}
	
	public void setEventID(String newEventID)
	{
		this.eventID = newEventID;
	}
	
	public void addAction(IActivityAction action)
	{
		actions.add(action);
	}
	
	public void setActions(Collection<IActivityAction> newActions)
	{
		this.actions = newActions;
	}
	
	public void addEventTrigger(EventTrigger eventTrigger)
	{
		this.eventTriggers.add(eventTrigger);
	}
	
	public void setEventTriggers(Collection<EventTrigger> newEventTriggers)
	{
		this.eventTriggers = newEventTriggers;
	}
	
	public Collection<EventTrigger> getEventTriggers()
	{
		return eventTriggers;
	}
	
	public Collection<IActivityAction> getActions()
	{
		return actions;
	}
}
